<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="referrer" content="no-referrer" />
    <title>3DTiles模型</title>
    <style>
        body {
            position: absolute;
            margin: 0;
            width: 100%;
            height: 100%;
        }

        #mapContainer {
            left: 0px;
            top: 0px;
            width: 100%;
            height: 100%;
            float: left;
        }
    </style>
</head>

<body>

    <div id="mapContainer" style="position: relative;">
    </div>

</body>
<script src='/GiswayEngine.js'></script>
<script type="text/javascript">
    window.app = new GE.App('mapContainer', {
        //兰溪
        // position: [119.32229022390463, 29.100791801021828, 1000],
        // lookAt: [119.32229022390463, 29.100791801021828, 0],

        //下姜村
        // position: [118.71870629387192, 29.377378045196107, 1500],
        // lookAt: [118.71870629387192, 29.377378045196107, 0],

        //烟台
        // position: [121.06480666564866, 37.68755563, 2000],
        // lookAt: [121.06480666564866, 37.68755563, 0],

        //辽东湾
        // position: [121.97978, 40.75601, 100],
        // lookAt: [121.97978, 40.75601, 0],

        //建刚生产的测试数据
        position: [121.97978, 40.75601, 200],
        lookAt: [121.97978, 40.75601, 0],

        //贵州
        // position: [108.0232, 26.4326, 2000],
        // lookAt: [108.0232, 26.4326, 0],

        //白洋淀
        // position: [115.97054690083002, 38.949655392764356, 2000],
        // lookAt: [115.97054690083002, 38.949655392764356, 0],

        //fbx转换到3dtiles的测试数据
        // position: [121.99824083179337, 40.71068467899703, 2000],
        // lookAt: [121.99824083179337, 40.71068467899703, 0],

        // position: [118.51031743575051, -0.0023777521580982193, 2000],
        // lookAt: [118.51031743575051, -0.0023777521580982193, 0],

        // fbx转到3dtiles的测试数据 //正在测试用的数据
        // position: [122.00151626214978, 40.71106690828059, 1000],
        // lookAt: [122.00151626214978, 40.71106690828059, 0],

        // position: [119.32229022390463, 29.100791801021828, 1000],
        // lookAt: [119.32229022390463, 29.100791801021828, 0],
        // position: [115.95616, 38.89975, 1500],
        // lookAt: [115.95616, 38.89975, , 0],
        cameraScrollSpeed: 15,
        minZoom: 16,
        maxZoom: 20,
        cameraFov: 15, //相机的fov
       
        ambientLightIntensity:2,
        ambientLightcolor:0xffffff,//环境光照的颜色
        ambientLightType:'ambient',//环境光照的类型，有如下类型:ambient，hemisphere
        supportLightType:'single',//方向光的类型，有如下类型:single，double，tripple
        supportLightIntensity:1,//方向光的强度
        supportLightcolor:'#ffffff', //方向光的颜色
        lightDistance:2000,//方向光源距离初始相机target的距离
        lightHeight:50,//方向光源的高度
        
        useCarpet: true,
        background: "none",
        useDefaultTexture: true, //是否使用瓦片默认纹理
        baseLayer: [
            {
                url: ' https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
                // url:'https://gis5.ldwzh.com:28015/pj16/{z}/{x}/{y}.png',
                readableUrl: true,
                tileType: 'image',
            },
        ]
    });

    var threeTileModel;
    tiles3d();
    function tiles3d() {//examples\resources\3dtiles\Data\tileset.json
        threeTileModel = new GE.Tiles3d({
            // url: 'http://localhost:9000/examples/resources/3dtiles/3Dtiles-3/tileset.json', refinement: 1, //loadRange: 100000,//白洋淀,
            // url: 'http://192.168.2.100:8702/resources/1b8b2fcb26b020120aebfac57779e06a/3dtiles/lanxi/3dtiles/tileset.json', refinement: 5, loadRange: 400, //兰溪
            // url: 'http://192.168.2.100:8702/resources/1b8b2fcb26b020120aebfac57779e06a/3dtiles/xiajiangcun/tileset.json', refinement: 10, loadRange: 300,//下姜村
            // url: 'http://192.168.2.100:8702/resources/1b8b2fcb26b020120aebfac57779e06a/3dtiles/guizhou/goodguizhou/tileset.json',refinement: 5, loadRange: 500,//贵州 还需要进一步测试
            // url: 'http://192.168.2.100:8702/resources/1b8b2fcb26b020120aebfac57779e06a/3dtiles/yantai/3DTiles/tileset.json', refinement: 50, loadRange: 800,//烟台
            // url: 'http://192.168.2.44:9000/examples/resources/3dtileszip/3dtiles/tileset.json', refinement: 1, loadRange: 100, //辽东湾
            url: 'http://192.168.2.44:9000/examples/resources/3dtiles/CIP/3dtileszip/3dtiles/tileset.json', refinement: 1, loadRange: 10,//建刚生产的测试数据
            // url: 'http://192.168.2.43:8081/baiyangdian/3Dtiles/tileset.json', refinement: 1, loadRange: 1000, //白洋淀
            // url: 'http://localhost:9000/examples/resources/3dtiles/ZGX2/tileset.json', refinement: 1, loadRange: 1000,//fbx转换到3dtiles的测试数据
            //  url: 'http://localhost:9000/examples/resources/3dtiles/test/3dtiles/root.json', refinement: 1000.0, loadRange: 10,//fbx转换到3dtiles的测试数据
            // url: 'http://localhost:9000/examples/resources/3dtiles/Data/tileset.json', refinement: 40, loadRange: 100000,
            // url: 'http://localhost:9000/examples/resources/3dtiles/分离/5/tileset.json', refinement: 1, loadRange: 1000,//fbx转换到3dtiles的测试数据
            // autoLocate: true,
            z: 0, //调整数据的高度
            minSize: 4000,
            maxSize: 8000,
            // screenErrorFactor: 40, //屏幕误差缩放的倍数
            // screenErrorFactor: 8400, //屏幕误差缩放的倍数
            isOpenAdditionalCamera: true, //是否添加预加载的额外相机
            additionCameraFov: 30, //额外相机的fov
            // unloadPercent: 0.01,
            maxJobs: 60,
            // minSize: 160,
            // maxSize: 300,
            isSupportTransparent: false,
            // isDoubleSide: true, //是否开启双面渲染
            //changeEmissive: true, //是否开启自发光
            //  geoSystem: '3857', //4978是椭球坐标系，3857是web墨卡托坐标系。这个参数可以不配置，默认是4978
            maxSlopeAngle: 25, //最大斜坡角度
            // isOnlyLoadCoarse: true, //是否只加载最粗略的瓦片
        });
        app.add(threeTileModel);
        window.tiles3d = threeTileModel;
    }

    let model;
    function fbx() {
        model = new GE.OverLay({
            type: 'fbx',
            falldownSurface: threeTileModel, //模型要贴到的底图上，可以是3dtiles，也可以是其他的底图(比如dem)
            // url: 'http://localhost:9000/examples/resources/fbx/xqazm.fbx',
            url: 'http://localhost:9000/examples/resources/fbx/FBX/2.FBX',
            // url: 'http://localhost:9000/examples/resources/fbx/ceshi1.FBX',
            // url:'http://192.168.2.43:9000/examples/resources/fbx/box.gltf',
            position: [108.0232, 26.4326, 60],
            changeEmissive: true,
            // scale: [100, 100, 100],
            // rotation: [45, 0, 0],
            success: function () {
            }
        })
        window.app.add(model);
    }
    fbx();

    window.app.on('Click', function (e) {
        console.log(e);
    });

    window.app.on('ZoomChange', function (e) {
        if(window.app.map.zoom  > 17){
            threeTileModel.isOnlyLoadCoarse = false;
            threeTileModel.screenErrorFactor = 1;
        }else{
            threeTileModel.isOnlyLoadCoarse = true;
            threeTileModel.screenErrorFactor = 100;
        }
    });

    // window.app.on('MapDragStart', function (e) {
    //     console.log('地图拖拽开始');
    // });
    // window.app.on('MapDragEnd', function (e) {
    //     console.log('地图拖拽结束');
    // });
</script>

</html>